﻿#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums)
    {
        int num = 0;
        for (auto e : nums)
        {
            num ^= e;
        }

        int lsb = (num == INT_MIN ? num : num & (-num));//取最后一位1
        int type1 = 0, type2 = 0;
        for (auto e : nums)
        {
            if (e & lsb)//以lsb分离两个不相同的数字
            {
                type1 ^= e;
            }
            else
            {
                type2 ^= e;
            }
        }
        return { type1,type2 };
    }
};


